--
-- Author: shunguo.chen
-- Date: 2018-02-06 14:30:49
--
-- MapInfo 地图基本信息

local fileName = string.getModeName(...)
local ClassRef = class(fileName)

function ClassRef:ctor(data)
    if data then
        self:init(data)
    end
end

-- data = "world_map" conf
function ClassRef:init(data) 
	self.id = tonumber(data.ID)
	self.openTask = tonumber(data.questId or 0)
	self.openLevel = tonumber(data.level or 0)

	self._conf = GD:queryMapById(self.id)

	self._icon = nil

	self._zones = {}
end

-- 添加区域
-- @param conf 区域配置
function ClassRef:addZone(zoneInfo)
	self._zones[#self._zones + 1] = zoneInfo
end

function ClassRef:getZones()
	return self._zones
end

function ClassRef:getZoneNumStr()
	local str = L("lua_code_text_12")
	return string.format(str, #self._zones)
end

function ClassRef:hasZone()
	return #self._zones > 0
end

-- 是否当前地图
function ClassRef:isCurMap()
	return self.id == MapManager:getMapId()
end

-- 是否开启
function ClassRef:isOpen()
	if self.openLevel > 0 and self.openLevel <= UD:getLevel() then
		return true
	end
	if self.openTask > 0 and UD:isMainTaskFinished(self.openTask) then
		return true
	end
	return false
end

function ClassRef:getName()
	return L(self._conf.string)
end

function ClassRef:getIcon()
	if not self._icon then
		self._icon = table.concat({"art/main_mapimg/", self._conf.icon, ".png"})
	end
	return self._icon
end


return ClassRef